package cn.afactory.tygz.ui.base.utils.sns;

import android.graphics.Bitmap;
import android.text.TextUtils;

import com.harwkin.nb.camera.album.ImageItem;
import com.harwkin.nb.camera.model.PicsItem;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author xiezhidong251@jk.cn
 * @Description
 * @date 2015/6/8.
 */
public class PhotoData implements Serializable {

    private static final long serialVersionUID = -1906482563991405164L;
    public String mTfsUrl;//图片所在服务器位置
    public String mLocalUrl;//图片所在本地位置
    public Bitmap mBmp;//图片
    public String mThumbnail;//缩略图

    public static PhotoData ImageItem2PhotoData(ImageItem im){
        PhotoData mp = new PhotoData();
        if (!TextUtils.isEmpty(im.imagePath)){
            mp.mLocalUrl = im.imagePath;
        }

        if(!TextUtils.isEmpty(im.thumbnailPath)){
            mp.mThumbnail = im.thumbnailPath;
        }
        return mp;
    }

    public static PhotoData ImageItem2PhotoData(PicsItem im){
        PhotoData mp = new PhotoData();
        if (!TextUtils.isEmpty(im.image)){
            mp.mLocalUrl = im.image;
        }
        return mp;
    }

    public static List<PhotoData> ImageItem2PhotoData(List<ImageItem> imlist){
        if(imlist == null ){
            return null;
        }
        List<PhotoData> mplist = new ArrayList<PhotoData>();
        for(ImageItem tmp : imlist){
            mplist.add(ImageItem2PhotoData(tmp));
        }
        return mplist;
    }

    public static PhotoData ImageItem2PhotoData(String im){
        PhotoData mp = new PhotoData();
        if (!TextUtils.isEmpty(im)){
            mp.mLocalUrl = im;
        }
        return mp;
    }

    public static List<PhotoData> String2PhotoData(List<String> imlist){
        if(imlist == null ){
            return null;
        }
        List<PhotoData> mplist = new ArrayList<PhotoData>();
        for(String tmp : imlist){
            mplist.add(ImageItem2PhotoData(tmp));
        }
        return mplist;
    }

    public static List<PhotoData> PicItem2PhotoData(List<PicsItem> imlist){
        if(imlist == null ){
            return null;
        }
        List<PhotoData> mplist = new ArrayList<PhotoData>();
        for(PicsItem tmp : imlist){
            mplist.add(ImageItem2PhotoData(tmp));
        }
        return mplist;
    }
}
